package cn.teamstack.logger.vo;

import cn.teamstack.logger.entity.LogFile;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: LogFileWrapper
 * @Description:
 * @Author: Donaldhan
 * @Date: 2020-06-01 10:26
 */
@Data
public class LogFileWrapper {
    /**
     * <logNamePrefix, List<LogFile>>
     */
    private Map<String, List<LogFile>> logFileMap = new HashMap<>();
    /**
     * @param logFile
     */
    public void putLogFile(String logName, LogFile logFile){
        List<LogFile> logFileList = logFileMap.get(logName);
        if(CollectionUtils.isEmpty(logFileList)){
            logFileList = new ArrayList<>();
            logFileMap.put(logName, logFileList);
        }
        logFileList.add(logFile);
    }
}
